package com.cloudkinto.common.utils;

import cn.afterturn.easypoi.excel.entity.result.ExcelVerifyHandlerResult;
import cn.afterturn.easypoi.handler.inter.IExcelVerifyHandler;
import cn.hutool.core.util.ObjectUtil;
import lombok.SneakyThrows;
import org.springframework.stereotype.Component;

/**
 * @author long
 * @Description excel导入校验
 * @Date 2024/12/31 17:29
 */
@Component
public class ClassExcelVerifyHandler implements IExcelVerifyHandler<Object> {
    @SneakyThrows(Exception.class)
    @Override
    public ExcelVerifyHandlerResult verifyHandler(Object obj) {
        ExcelVerifyHandlerResult result = new ExcelVerifyHandlerResult(true);
        if (ObjectUtil.isNotNull(obj)) {
            //判断对象属性是否全部为空
            boolean b = ObjectIsNullUtil.checkFieldAllNull(obj);
            result.setSuccess(!b);
        }
        return result;
    }
}